let page = 1;
let pageSize = 4;
let html;
let Url = JSON.stringify(location.href);
let index = Url.indexOf("="); //传的值
let keyword = ""; //传的参数名


let that = null;
$(
    function init() {
        getData();
        checkShopLogin();
    }

)

function checkShopLogin() {
    let userInfo = checkLoginName();
    console.log("userInfo" + userInfo);
    let html = template("userTpl", { userInfo });
    console.log(html);
    $("#userName").html(html);

}

function getData() {
    if (!that) {
        that = this;
    }

    $.ajax({
        url: "/product/queryProduct",
        type: "get",
        data: {
            proName: keyword,
            page: page++,
            pageSize: pageSize,
        },
        success: function(res) {
            console.log(res);
            if (res.data.length > 0) {
                console.log("data" + res.data);
                html = template("shopTpl", { data: res.data });
                console.log(html);
                $("#shopItem").html(html);
            }
        }
    })
}